package com.hrt.iceberg.unauto

import org.apache.spark.sql.SparkSession

/**
 * 读取iceberg的数据
 */
object ReadDataFromIceberg {
  def main(args: Array[String]): Unit = {
    //1.创建SparkSession
    val spark: SparkSession = SparkSession.builder().master("local").appName("SparkOperateIceberg")
      //设置Hadoop Catalog
      .config("spark.sql.catalog.hadoop_prod", "org.apache.iceberg.spark.SparkCatalog")
      .config("spark.sql.catalog.hadoop_prod.type", "hadoop")
      .config("spark.sql.catalog.hadoop_prod.warehouse", "hdfs://hadoop102:8020/sparkoperaticeberg")
      .config("spark.sql.extensions","org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions")
      .getOrCreate()

    spark.sql("select * from hadoop_prod.iceberg_db.iceberg_tbl").show()
  }

}
